package com.hzy.admin.controller.core;

import com.hzy.framework.controller.BaseController;
import com.hzy.toolkit.NEditorUtils;

import java.util.HashMap;
import java.util.Map;

import com.hzy.toolkit.UploadFileUtils;
import net.sf.jsqlparser.expression.operators.relational.OldOracleJoinBinaryExpression;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * neditor 编辑器上传 服务
 *
 * @author hzy
 */
@RequestMapping("/upload")
@RestController
public class UploadController extends BaseController {

    /**
     * 上传图片
     *
     * @param files
     * @return
     * @throws Exception
     */
    @ResponseBody
    @PostMapping("/images")
    public Map<String, Object> images(@RequestParam("editorFileImages") final MultipartFile[] files) throws Exception {
        Map<String, Object> map = new HashMap<String, Object>(2);
        map.put("errno", 0);
        map.put("data", UploadFileUtils.save(files));
        return map;
    }

}
